import java.util.*;
public class Practice4 {
    static char[] ss;
    static int n;
    static int[] hash;
    public static void main(String[] args) {
        //https://ac.nowcoder.com/acm/contest/71300/E
        //没有解出来明天再想
        Scanner sc = new Scanner(System.in);
        int count = 0;

        Random random = new Random();
        int t = random.nextInt(100);

        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < t; i++) {
            int m = random.nextInt(26);
            stringBuilder.append((char)(m + 'a'));
        }
        ss = stringBuilder.toString().toCharArray();
        n = t;
        System.out.println(check1());//解法一
        System.out.println(check2());//解法二
    }

    private static int check2() {
        int count = 0;
        hash = new int[26];

        hash[ss[n - 1] - 'a']++;
        hash[ss[n - 2] - 'a']++;
        for(int i = n - 3;i >= 0;i--){
            for(int j = 0;j < 26;j++){
                if(hash[j] > 1 && ss[i] != (char)('a' + j)){
                    count += hash[j] * (hash[j] - 1) / 2;

                }
            }
            hash[ss[i] - 'a']++;
        }
        return count;
    }

    private static int check1() {
        int count = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for(int k = j + 1;k < n;k++){
                    if(ss[j] == ss[k]){
                        count++;
                    }
                }
            }
        }
        return count;
    }
}
